package com.atguigu.cloud.resp;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author yuanx
 * @date 2024/3/3 23:16
 */
@Data
@Accessors(chain = true)
public class ResultData<T> {
    private String code;
    private String msg;
    private T data;
    private long timeStamp;

    public ResultData(){
        this.timeStamp=System.currentTimeMillis();
    }
    public static <T>  ResultData<T> success(T data) {
        ResultData<T> apiResult = new ResultData();
        apiResult.setCode(ReturnCodeEnum.RC200.getCode());
        apiResult.setData(data);
        apiResult.setMsg(ReturnCodeEnum.RC200.getMsg());
        return apiResult;
    }

    public static <T>  ResultData<T> fail(String code,String msg) {
        ResultData<T> apiResult = new ResultData();
        apiResult.setCode(code);
        apiResult.setMsg(msg);
        return apiResult;

    }
}
